package com.zhanggm.springboot.springbootdemo05.task;

import com.zhanggm.springboot.springbootdemo05.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
public class TaskService {
    @Autowired
    OrderService orderService;
      //固定时间执行任务
//    @Scheduled(fixedRate = 1000)
      //任务结束后，1秒再次执行该任务
//    @Scheduled(fixedDelay = 1000)
    @Scheduled(cron = "0/59 * * * * ?")
    public void cannelOrder(){
        //查询所有未支付的订单，循环取消订单
        orderService.cannelOrder();
    }


}
